package test.api.feign.api;

import feign.Logger;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

/**
 * @Author wangshaopeng
 * @Date 2020/11/8
 */
@FeignClient(configuration = FeignHelloApi.HelloConfig.class,path="/")
public interface FeignHelloApi {


    @GetMapping("/hello")
    String hello(@RequestParam("name") MultipartFile name, @RequestHeader("X-header") String h1);



    class HelloConfig{
        @Bean
        RequestInterceptor interceptor(){
            return new RequestInterceptor() {
                @Override
                public void apply(RequestTemplate requestTemplate) {
                    System.out.println("hello");

                }
            };
        }


        @Bean
        feign.Logger.Level level(){
            System.out.println("hello-basic");
            return Logger.Level.BASIC;
        }
    }
}
